<extend name="Base:main" />
<block name="content">
    <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                分销锁库订单详情
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li><a href="#">锁库订单</a></li>
                <li class="am-active">订单详情</li>
            </ol>
            <div class="tpl-portlet-components">
                <div class="portlet-title">
                      <div class="caption font-green bold">
                        <span class="am-icon-code"></span>详情
                    </div>
                </div>
                <div class="tpl-block ">

                    <div class="am-g tpl-amazeui-form">


                        <div class="am-u-sm-12 am-u-md-9">
                             <form class="am-form am-form-horizontal" name='myfromSubmit'>
                     
							 
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">订单编号</label>
									<div class="am-u-sm-7 float_left">
										{$info.sn}
									</div>
							</div>
							 <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">商品名</label>
									<div class="am-u-sm-7 float_left">
										{$info.name}
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">en13码</label>
									<div class="am-u-sm-7 float_left">
										{$info.earn13}
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">供应商</label>
									<div class="am-u-sm-7 float_left">
										{$info.shop_name}
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">商品数量</label>
									<div class="am-u-sm-7 float_left">
										{$info.stock_num}
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">单价 / 总价</label>
									<div class="am-u-sm-7 float_left">
										<span style="font-size:12px;">￥</span>{$info.single_price} / <span style="font-size:12px;">￥</span>{$info.total_price}
									</div>
							</div>
                            <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">支付方式</label>
									<div class="am-u-sm-7 float_left">
                                    	<?php 
                                        	$lock_pay_rule = $info['lock_pay_rule'] ? unserialize($info['lock_pay_rule']) : ''; 
                                            $pay_price_scale = 1;
                                        	if( $lock_pay_rule ) {
                                            	$pay_price_scale = $lock_pay_rule['lock'] / 100;
                                            }
                                        ?>
                                    	<switch name="info.lock_pay_type">
                                        	<case value="1">一次性支付</case>
                                        	<case value="2">分两次支付 - <span style="color:red">锁货支付：{$lock_pay_rule.lock}%</span> - 收货前支付：{$lock_pay_rule.received}%</case>
                                        	<case value="3">分三次支付 <span style="color:red">- 锁货支付：{$lock_pay_rule.lock}%</span> - 下单后支付：{$lock_pay_rule.down}% - 收货前支付：{$lock_pay_rule.received}%</case>
                                        </switch>
									</div>
							</div>
                            <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">应支付金额</label>
									<div class="am-u-sm-7 float_left">
										<span style="font-size:12px;">￥</span>{$info['pay_total_price']}
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">订单状态</label>
									<div class="am-u-sm-7 float_left">
										<eq name="info.status" value="1"><span style="color:green">已支付</span><else/><span style="color:red">未支付</span></eq>
									</div>
							</div>
                            <eq name="info.status" value="0">
							<style>
								.pay_class_type,.pay_class_type dl{ width:100%; }
								.pay_class_type dl dd{ width:120px; height:40px; border:1px solid #ccc; float:left; text-align:center; line-height:40px; font-size:14px; margin-right:10px;}
								.pay_class_type dl dd.active{ background:#0e90d2; border:1px solid #0e90d2; color:#fff; }
							</style>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">支付方式</label>
									<div class="am-u-sm-9 float_left">
										<div class="pay_class_type">
											<dl>
												<neq name="info.alipay_pay_id" value="0">
												<dd data-payid="{$info.alipay_pay_id}">支付宝</dd>
												</neq>
												<neq name="info.weixin_pay_id" value="0">
												<dd data-payid="{$info.weixin_pay_id}">微信</dd>
												</neq>
												<dd data-payid="preset">预存款</dd>
											</dl>
										</div>
									</div>
							</div>
							<div class="am-form-group" style="display:none" id="money">
									<label for="user-email" class="am-u-sm-3 am-form-label">预存款</label>
									<div class="am-u-sm-7 float_left">
										<span style="font-size:12px;">￥</span>{$local_price}
									</div>
							</div>
							<div class="am-form-group">
								<div class="am-u-sm-9 am-u-sm-push-3">
									<button type="button" id="ok_submit_pay" class="am-btn am-btn-primary">确认立即支付</button>
								</div>
							</div>
                            <else />
                            <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">支付方式</label>
									<div class="am-u-sm-7 float_left">
										<switch name="info.payment_type">
                                        	<case value="Alipay">支付宝</case>
                                        	<case value="Weixin">微信</case>
                                        	<case value="Preset">预存款</case>
                                        </switch>
									</div>
							</div>
							<neq name="info.payment_type" value="Preset">
                            <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">支付单</label>
									<div class="am-u-sm-7 float_left">
                                    	{$info.payment_no}
									</div>
							</div>
							</neq>
                            <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">支付时间</label>
									<div class="am-u-sm-7 float_left">
                                    	{$info.pay_time}
									</div>
							</div>
                            </eq>
						</form>
					</div>
				</div>
			</div>

		</div>

        </div>
		<script type="text/javascript">
				var goods_type_id = $('#goods_type').val();
				if(goods_type_id){
					$('#goods_type_id option').each(function(){
						  if( goods_type_id == $(this).attr('value') ) {
							  $(this).attr('selected' , true);
							  return false;
						  } 
					   }); 
				}
				$('.pay_class_type dl dd').click(function(){
					$('.pay_class_type dd.active').removeClass('active');
					$(this).addClass('active');
					if( $(this).attr('data-payid' ) == "preset" ) {
						$('#money').show();
					} else {
						$('#money').hide();
					}
				});
				$('#ok_submit_pay').click(function(){
					if( $('.pay_class_type dl dd.active').length != 1 ) {
						error('请选择支付方式');
						return false;
					}
					var pay_id = $('.pay_class_type dl dd.active').attr('data-payid');
					if( pay_id == '' ) {
						error('请选择支付方式');
						return false;
					}
					
					if( pay_id == 'preset' ) {
						<?php if( $local_price == '0.00' ) : ?>
						error('账户金额不足,请充值之后再支付');
						return false;
						<?php else : ?>
						if( parseFloat({$local_price}) < parseFloat({$info['pay_total_price']}) ) {
							error('账户金额不足,请充值之后再支付');
							return false;
						}
						<?php endif;?>
					}
					
					zeroModal.confirm({
						content: '支付成功了吗？',
						buttons: [
							{ className: 'zeromodal-btn zeromodal-btn-primary', name: '支付成功', fn:function(opt){ location.reload() }},
							{ className: 'zeromodal-btn zeromodal-btn-default', name: '失败了', fn:function(opt){  }}
						]
					});

					window.open(getUrl('Pay/pay' , { 'pay_id' : pay_id,'type':'lock','id':'{$Think.get.sn}' }));
				});
		</script>
</block>